﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GUILibrary
{
    public class MultiTextBox : TextBox, ActionListener
    {

        /// <summary>
        /// The text to display in this text box for each action.
        /// </summary>
        public Dictionary<string, string> ActionToText
        {
            get;
            set;
        }

        private string defaultText;

        public void UpdateAction(List<string> currentActions)
        {
            if (currentActions.Count == 0)
            {
                TextToDisplay = defaultText;
                return;
            }

            bool found = false;
            foreach (string action in currentActions)
            {
                if (ActionToText.ContainsKey(action))
                {
                    TextToDisplay = ActionToText[action];
                    found = true;
                    break;
                }
            }

            if (!found)
                TextToDisplay = defaultText;
        }

        public override void Load(Microsoft.Xna.Framework.Content.ContentManager cm)
        {
            base.Load(cm);

            defaultText = TextToDisplay;
        }
    }
}
